<template>
  <view class="demo-container">
    <!-- 基础用法 -->
    <view class="demo-block">
      <view class="demo-block__title">基础用法</view>
      <view class="demo-block__content">
        <fu-grid>
          <fu-grid-item 
            v-for="i in 8" 
            :key="i"
            :icon="'&#xe6e' + i"
            :text="`文本${i}`"
          />
        </fu-grid>
      </view>
    </view>
    
    <!-- 自定义列数 -->
    <view class="demo-block">
      <view class="demo-block__title">自定义列数</view>
      <view class="demo-block__content">
        <fu-grid :column-num="3">
          <fu-grid-item 
            v-for="i in 6" 
            :key="i"
            :icon="'&#xe6e' + i"
            :text="`文本${i}`"
          />
        </fu-grid>
      </view>
    </view>
    
    <!-- 格子间距 -->
    <view class="demo-block">
      <view class="demo-block__title">格子间距</view>
      <view class="demo-block__content">
        <fu-grid :gutter="10">
          <fu-grid-item 
            v-for="i in 8" 
            :key="i"
            :icon="'&#xe6e' + i"
            :text="`文本${i}`"
          />
        </fu-grid>
      </view>
    </view>
    
    <!-- 正方形格子 -->
    <view class="demo-block">
      <view class="demo-block__title">正方形格子</view>
      <view class="demo-block__content">
        <fu-grid square>
          <fu-grid-item 
            v-for="i in 8" 
            :key="i"
            :icon="'&#xe6e' + i"
            :text="`文本${i}`"
          />
        </fu-grid>
      </view>
    </view>
    
    <!-- 自定义内容 -->
    <view class="demo-block">
      <view class="demo-block__title">自定义内容</view>
      <view class="demo-block__content">
        <fu-grid :column-num="3">
          <fu-grid-item>
            <image 
              src="/static/images/1.jpg"
              mode="aspectFill"
              class="grid-image"
            />
          </fu-grid-item>
          <fu-grid-item>
            <view class="custom-content">
              <text>自定义</text>
              <text>内容</text>
            </view>
          </fu-grid-item>
          <fu-grid-item>
            <fu-button 
              type="primary"
              size="mini"
            >按钮</fu-button>
          </fu-grid-item>
        </fu-grid>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  methods: {
    onClick(index) {
      uni.showToast({
        title: `点击了第${index + 1}个格子`,
        icon: 'none'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.demo-container {
  padding: 20rpx;
}

.demo-block {
  margin-bottom: 30rpx;
  
  &__title {
    margin-bottom: 20rpx;
    font-size: var(--fu-font-size-lg);
    color: var(--fu-text-color);
  }
  
  &__content {
    border-radius: var(--fu-radius-base);
    overflow: hidden;
  }
}

.grid-image {
  width: 100rpx;
  height: 100rpx;
  border-radius: var(--fu-radius-base);
}

.custom-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--fu-primary-color);
  font-size: 28rpx;
  line-height: 1.5;
}
</style> 